Skip to content

Comments

[INTP-368] chore: Update CI repository refs, enhance client error reporting, and stabilize test DB restores#1240

Merged
pedroven merged 23 commits intomainfrom
INTP-368
Feb 5, 2026
Merged

[INTP-368] chore: Update CI repository refs, enhance client error reporting, and stabilize test DB restores#1240
pedroven merged 23 commits intomainfrom
INTP-368

Conversation

@pedroven
Copy link
Collaborator

@pedroven pedroven commented Jan 28, 2026

Related issues

Proposed changes

This pull request introduces a set of maintenance and reliability improvements targeting both the continuous integration workflow as well as the test infrastructure and client error reporting. The following major changes are included:

  1. CI Workflow Repository Reference Fix:

    • The repository reference in the GitHub Actions workflow (ci.yml) is updated from ankipalace/ankihub to AnkiHubSoftware/ankihub to reflect the correct repository location.
    • The checkout step name is also adjusted for clarity.
  2. Improved Client Error Reporting:

    • The string representation of the AnkiHubHTTPError exception in ankihub_client.py now includes the response content, not just the status code and reason. This change provides more diagnostic context in error logs, especially for unexpected HTTP failures.
    try:
        response_text = self.response.text
    except Exception:
        response_text = "Unable to read response content"
    return f"AnkiHub request error: {self.response.status_code} {self.response.reason}\n{response_text}"
  3. Type Consistency Fix in Tutorial Code:

    • TutorialStep.back_callback's type is corrected for consistency with next_callback: it now expects a Callable accepting a callback argument, not just a parameterless lambda.
  4. Robust Database Restore in Integration Tests:

    • The integration test fixture in test_client.py has improved logic for database restoration:
      • Instead of using a standard pg_restore --clean, a filtered table of contents (TOC) is generated that skips the SCHEMA entry. This avoids attempts to drop the schema, which can fail if extensions are present.
      • The TOC filtering is performed via pg_restore -l | grep -v ' SCHEMA ' and the filtered TOC (restore_toc.list) is then used with the -L option of pg_restore.
      • This ensures a more reliable and repeatable restore of test databases, especially when using Postgres extensions (e.g., pg_trgm, vector).
      • Additional options --if-exists and --jobs=4 help with idempotency and faster restore operations.

Further comments

PR Dependency: To make the tests for this PR pass, the changes in this PR (https://github.com/AnkiHubSoftware/ankihub/pull/3340) need to be merged into the ankihub repository first. The integration tests rely on backend changes introduced there.

Test DB Restore Logic: The main motivation for the update was to address unreliable restores when using Postgres extensions, which can cause DROP SCHEMA to fail and require container-level intervention. We now surgically reset only the necessary DB objects for tests while maintaining extensions.

Richer HTTP Error Messages: These should make debugging network/client integration issues faster—the raw response often includes error messages from the API that were previously hidden from the logs.

Potential risks: - The new TOC filtering method for pg_restore assumes consistent Postgres dump behavior; future major Postgres version upgrades may alter this syntax or require TOC filtering tweaks.

In rare edge cases, errors in reading the HTTP response content could still obscure the payload (handled defensively).

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @pedroven, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of the client database setup process by adding a conditional flag to the pg_restore command, preventing potential errors during restoration. Additionally, it refines the database dumping mechanism by specifying table patterns more precisely, ensuring that only relevant data within the public schema is included in the dump.

Highlights

  • Client Setup Robustness: The pg_restore command used during client setup now includes the --if-exists flag, ensuring that only existing database objects are dropped before restoration, preventing errors if objects are missing.
  • Database Dump Precision: The pg_dump command has been refined to use -t 'public.*' instead of --schema=public, which provides more precise table selection within the public schema for database dumps.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pedroven pedroven changed the title Add --if-exists flag to client setup and refine db dump command [INTP-368] chore: Update CI repository refs, enhance client error reporting, and stabilize test DB restores Jan 30, 2026
@pedroven pedroven requested a review from Copilot January 30, 2026 14:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Maintenance and reliability updates spanning CI configuration, client error visibility, tutorial typing consistency, and integration test DB restore stability.

Changes:

  • Update GitHub Actions workflow to checkout the webapp repo from AnkiHubSoftware/ankihub.
  • Enhance AnkiHubHTTPError string output to include response content for better diagnostics.
  • Improve integration test DB restore logic by generating a filtered pg_restore TOC list that excludes schema drops; add --if-exists.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/client/test_client.py Switch DB restore to use a filtered pg_restore TOC list and add restore flags for more robust resets with extensions.
ankihub/gui/tutorial.py Align back_callback typing with next_callback to accept an on_done callback.
ankihub/ankihub_client/ankihub_client.py Expand HTTP error string output to include response body for debugging.
.github/workflows/ci.yml Update webapp repo checkout reference and tweak step naming.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pedroven pedroven marked this pull request as ready for review February 5, 2026 17:17
abdnh
abdnh previously approved these changes Feb 5, 2026

def ensure_mw_state(state: str) -> Callable[[...], None]:
def change_state_and_call_func(func: Callable[[...], None], *args: Any, **kwargs: Any) -> None:
MainWindowStateLiteral = Literal["startup", "deckBrowser", "overview", "review", "resetRequired", "profileManager"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use aqt.main.MainWindowState (used below)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I didn't notice, thank you!

@pedroven pedroven merged commit f746a19 into main Feb 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants